﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ViMap.Controllers
{
    public class SearchController : Controller
    {
        //
        // GET: /Search/

        public ActionResult Index()
        {
            return View();
        }

        [HttpGet]
        public ActionResult searchPlace()
        {
            return View("Index");
        }

        [HttpPost]
        public ActionResult searchPlace(FormCollection collection)
        {
            ViewData["currCity"] = collection["currCity_1"].ToString();
            ViewData["address"] = collection["address"].ToString();
            return View("PlaceSearch");
        }

        [HttpGet]
        public ActionResult searchRoute()
        {
            return View("Index");
        }

        [HttpPost]
        public ActionResult searchRoute(FormCollection collection) 
        {
            ViewData["hasStartPoint"] = collection["hasStartPoint"].ToString();
            ViewData["hasEndPoint"] = collection["hasEndPoint"].ToString();

            ViewData["placeIdStart"] = collection["placeIdStart"].ToString(); 
            ViewData["placeIdEnd"] = collection["placeIdEnd"].ToString(); 
            
            ViewData["start_location"] = collection["start_location"].ToString(); 
            ViewData["end_location"] = collection["end_location"].ToString(); 
           
            ViewData["isGStartPoint"] = collection["isGStartPoint"].ToString(); 
            ViewData["isGEndPoint"] = collection["isGEndPoint"].ToString();

            ViewData["currCity"] = collection["currCity_2"].ToString();

            if (collection["hasStartPoint"] == "false")
            {
                return View("StartSearch");
            }

            if (collection["hasEndPoint"] == "false")
            {
                return View("EndSearch");
            }

            return View("RouteResult");
        }
    }
}
